package com.ndp.fb.enums.productfeed;

/**
 * Created by Evan on 2016/4/25.
 */

import lombok.Getter;

/**
 * feed更新中 catalog的状态
 * Created by Evan on 2016/4/20.
 */
@Getter
public enum CatalogStatus {

    /**
     * 更新中
     */
    UPDATING("updating", 1),

    UPDATE_OK("update_ok", 2),
    UPDATE_FAIL("update_fail", 3);
    /**
     *status
     */
    private String status;

    /**
     *code
     */
    private int code;

    CatalogStatus(String status, int code) {
        this.status = status;
        this.code = code;
    }

    /**
     * 根据code获取CatalogStatus
     * @param code code
     * @return Status
     */
    public static CatalogStatus getStatus(int code) {
        for (CatalogStatus c : CatalogStatus.values()) {
            if (c.code == code) {
                return c;
            }
        }
        return null;
    }

    /**
     * 根据status获取CatalogStatus
     * @param status status
     * @return Status
     */
    public static CatalogStatus getStatus(String status) {
        for (CatalogStatus c : CatalogStatus.values()) {
            if (c.status.equals(status)) {
                return c;
            }
        }
        return null;
    }
}